#ifndef ELF_H
#define ELF_H

#define ELF_MAGIC		0x464C457F

#define E_TYPE			0x10
#define E_MACHINE		0x12
#define E_VERSION		0x14
#define E_ENTRY			0x18
#define E_PHOFF			0x1C
#define E_SHOFF			0x20
#define E_FLAGS			0x24
#define E_EHSIZE		0x28
#define E_PHENTSIZE		0x2A
#define E_PHNUM			0x2C
#define E_SHENTSIZE		0x2E
#define E_SHNUM			0x30
#define E_SHSTRNDX		0x32

#define P_TYPE			0x0
#define P_OFFSET		0x4
#define P_VADDR			0x8
#define P_PADDR			0xC
#define P_FILEZS		0x10
#define P_MEMSZ			0x14
#define P_FLAGS			0x18
#define P_ALIGN			0x1C

#ifndef __ASSEMBLER__

#define EI_NIDENT		16

typedef struct {
	uint8_t		e_ident[EI_NIDENT];
	uint16_t	e_type;
	uint16_t	e_machine;
	uint32_t	e_version;
	uint32_t	e_entry;
	uint32_t	e_phoff;
	uint32_t	e_shoff;
	uint32_t	e_flags;
	uint16_t	e_ehsize;
	uint16_t	e_phentsize;
	uint16_t	e_phnum;
	uint16_t	e_shentsize;
	uint16_t	e_shnum;
	uint16_t	e_shstrndx;
} Elf32_Ehdr;

typedef struct {
	uint32_t	p_type;
	uint32_t	p_offset;
	uint32_t	p_vaddr;
	uint32_t	p_paddr;
	uint32_t	p_filesz;
	uint32_t	p_memsz;
	uint32_t	p_flags;
	uint32_t	p_align;
} Elf32_Phdr;

#endif // __ASSEMBLER__

#endif // ELF_H
